<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-student-edit" th:object="${student}">
            <input id="stuId" name="stuId" th:field="*{stuId}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">学生名称：</label>
				<div class="col-sm-8">
					<input id="stuName" name="stuName" th:field="*{stuName}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">显示顺序：</label>
				<div class="col-sm-8">
					<input id="orderNum" name="orderNum" th:field="*{orderNum}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">学生号：</label>
				<div class="col-sm-8">
					<input id="stuNum" name="stuNum" th:field="*{stuNum}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">班级号：</label>
				<div class="col-sm-8">
					<input id="classNo" name="classNo" th:field="*{classNo}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">性别：</label>
				<div class="col-sm-8">
					<select id="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">生日：</label>
				<div class="col-sm-8">
					<input id="birthday" name="birthday" th:field="*{birthday}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="${student.status == '0' ? true : false}" class="onoffswitch-checkbox" id="status" name="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">删除标志（0代表在读 2代表已毕业）：</label>
				<div class="col-sm-8">
					<!--<input id="delFlag" name="delFlag" th:field="*{delFlag}" class="form-control" type="text">-->
						<select id="delFlag" class="form-control m-b" th:with="type=${@dict.getType('sys_teacher_status')}">
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/student"
		$("#form-student-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});

		function submitHandler() {
	        // if ($.validate.form()) {
	        //     $.operate.save(prefix + "/edit", $('#form-student-edit').serialize());
	        // }
            edit();
	    }
        function edit() {
            var stuId = $("input[name='stuId']").val();
            var stuName = $("input[name='stuName']").val();
            var orderNum = $("input[name='orderNum']").val();
            var stuNum = $("input[name='stuNum']").val();
            var birthday=$("input[name='birthday']").val();
            var classNo = $("input[name='classNo']").val();
            var sex = $("#sex option:selected").val();
            var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
            var delFlag = $("#delFlag option:selected").val();
            $.ajax({
                cache : true,
                type : "POST",
                url : ctx + "system/student/edit",
                data : {
                    "stuId": stuId,
                    "orderNum": orderNum,
                    "stuName": stuName,
                    "stuNum": stuNum,
                    "classNo": classNo,
					 "birthday":birthday,
                    "sex": sex,
                    "status": status,
                    "delFlag": delFlag
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
            });
        }
	</script>
</body>
</html>
